import request from '@/utils/request'

export function getData() {
  return request({
    url: `/iot/data/`,
    method: 'get'
  })
}

export function getIndoorAirThreshold() {
  return request({
    url: `/iot/data/get_indoor_air_threshold/`,
    method: 'get'
  })
}

export function getOutdoorAirThreshold() {
  return request({
    url: `/iot/data/get_outdoor_air_threshold`,
    method: 'get'
  })
}

export function getRainThreshold() {
  return request({
    url: `/iot/data/get_rain_threshold`,
    method: 'get'
  })
}

export function getSoilThreshold() {
  return request({
    url: `/iot/data/get_soil_threshold`,
    method: 'get'
  })
}

export function getLaserThreshold() {
  return request({
    url: `/iot/data/get_laser_threshold`,
    method: 'get'
  })
}

export function getCordThreshold() {
  return request({
    url: `/iot/data/get_cord_threshold`,
    method: 'get'
  })
}

export function updateIndoorAirThreshold(data) {
  return request({
    url: `/iot/data/update_indoor_air_threshold`,
    method: 'post',
    data
  })
}
export function updateOutdoorAirThreshold(data) {
  return request({
    url: `/iot/data/update_outdoor_air_threshold`,
    method: 'post',
    data
  })
}
export function updateRainThreshold(data) {
  return request({
    url: `/iot/data/update_rain_threshold`,
    method: 'post',
    data
  })
}
export function updateSoilThreshold(data) {
  return request({
    url: `/iot/data/update_soil_threshold`,
    method: 'post',
    data
  })
}
export function updateLaserThreshold(data) {
  return request({
    url: `/iot/data/update_laser_threshold`,
    method: 'post',
    data
  })
}
export function updateCordThreshold(data) {
  return request({
    url: `/iot/data/update_cord_threshold`,
    method: 'post',
    data
  })
}
export function error_data_export(params) {
  return request({
    url: `/iot/data/error_data_export`,
    method: 'get',
    params
  })
}

const wariningMsgList = {
  deviceName: {
    label: '传感器类型',
    center: true,
    sort: true,
    show: true,
    type: 'string',
    disabled: false,
    width: 0
  },
  type: {
    label: '传感器',
    center: true,
    sort: true,
    show: true,
    type: 'string',
    disabled: false,
    width: 0
  }, data: {
    label: '报警数值',
    center: true,
    sort: true,
    show: true,
    type: 'string',
    disabled: false,
    width: 0
  }, rank: {
    label: '报警级别',
    center: true,
    sort: true,
    show: true,
    type: 'string',
    disabled: false,
    width: 0
  }, createTime: {
    label: '报警时间',
    center: true,
    sort: true,
    show: true,
    type: 'string',
    disabled: false,
    width: 0
  }
}

const warningList = {
  name: {
    label: '传感器类型',
    center: true,
    sort: true,
    show: true,
    type: 'string',
    disabled: false,
    width: 0,
    rule: () => {
      return new Error()
    }
  },
  unit: {
    label: '单位',
    center: true,
    sort: true,
    show: true,
    type: 'string',
    disabled: false,
    width: 0
  },
  threshold: {
    label: '传感器阈值',
    center: true,
    show: true,
    sort: true,
    type: 'string',
    disabled: false,
    width: 0
  }
}
export function warning() {
  return warningList
}

export function warningMsg() {
  return wariningMsgList
}

